{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 31.8 Primality testing"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 31.8-1\n",
    "\n",
    "> Prove that if an odd integer $n > 1$ is not a prime or a prime power, then there exists a nontrivial square root of $1$ modulo $n$."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 31.8-2 $\\star$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 31.8-3\n",
    "\n",
    "> Prove that if $x$ is a nontrivial square root of $1$, modulo $n$, then $\\text{gcd}(x - 1, n)$ and $\\text{gcd}(x + 1, n)$ are both nontrivial divisors of $n$."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "$$\n",
    "\\begin{array}{rlll}\n",
    "x^2 &\\equiv& 1 & (\\text{mod}~ n) \\\\\n",
    "x^2 - 1 &\\equiv& 0 & (\\text{mod}~ n) \\\\\n",
    "(x + 1) (x - 1) &\\equiv& 0 & (\\text{mod}~ n) \\\\\n",
    "\\end{array}\n",
    "$$\n",
    "\n",
    "$n ~|~ (x + 1)(x - 1)$, suppose $\\text{gcd}(x - 1, n) = 1$, then $n ~|~ (x + 1)$, then $x \\equiv -1 ~(\\text{mod}~ n)$ which is trivial, it contradicts the fact that $x$ is nontrivial, therefore $\\text{gcd}(x - 1, n) \\ne 1$, $\\text{gcd}(x + 1, n) \\ne 1$."
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
